<?php
global $wpdb;

$sql = 
		"
			SELECT 
				uc.sitemap,
				uc.userBlog,
				uc.active
			FROM ".$wpdb->prefix."hfr_url_craw uc
			WHERE 1 
		";
$rows = $wpdb->get_results($sql);

?>

<div class="hfr-body">
    <h2 class="title">Source Manager</h2>
    <div id="hfr-toolbar">
        <ul class="subsubsub">
        <li class="source"><a class="current" href="#">List Source</a> |</li>
        <li class="add-source"><a href="admin.php?page=hfr_source_manager&act=new">Add Source</a> |</li>
        <li class="sync-source"><a href="admin.php?page=hfr_source_manager&act=sync">Sync Source From Server Hatforrent</a></li>
    </ul>
    </div>
    <div style="clear:both;"></div>
    <table cellspacing="0" class="wp-list-table widefat fixed posts">
        <thead>
            <tr>
                <th style="" class="manage-column column-cb check-column" id="cb" scope="col">
                    <label for="cb-select-all-1" class="screen-reader-text">Select All</label>
                    <input type="checkbox" id="cb-select-all-1">
                </th>
                <th style="" class="manage-column column-title sortable desc" id="sitemap" scope="col">
                    <a href="#">
                        <span>Sitemap</span><span class="sorting-indicator"></span> 
                    </a>
                </th>
                <th style="" class="manage-column column-title sortable desc" id="userblog" scope="col">
                    <a href="#">
                        <span>User Blog</span><span class="sorting-indicator"></span> 
                    </a>
                </th>
                <th style="" class="manage-column column-date sortable asc" id="active" scope="col">
                    <a href="#">
                        <span>Status</span><span class="sorting-indicator"></span> 
                    </a>
                </th>
            </tr>
        </thead>
    
        <tfoot>
            <tr>
                <th style="" class="manage-column column-cb check-column" scope="col">
                    <label for="cb-select-all-2" class="screen-reader-text">Select All</label>
                    <input type="checkbox" id="cb-select-all-2">
                </th>
                <th style="" class="manage-column column-title sortable desc" scope="col">
                    <a href="#">
                        <span>Sitemap</span><span class="sorting-indicator"></span>
                    </a>
                </th>
                <th style="" class="manage-column column-title sortable desc" scope="col">
                    <a href="#">
                        <span>User Blog</span><span class="sorting-indicator"></span>
                    </a>
                </th>
                <th style="" class="manage-column column-date sortable asc" scope="col">
                    <a href="#">
                        <span>Status</span>
                        <span class="sorting-indicator"></span>
                    </a>
                </th>
            </tr>
        </tfoot>
    
        <tbody id="the-list">
<?php        
			for($i=0; $i < count( $rows ); $i++) {
				$row = $rows[$i];
?>
            <tr valign="top" class="post-<?php echo $i+1?> type-post status-publish format-standard hentry category-uncategorized  iedit author-self" id="post-<?php echo $i+1?>">
                <th class="check-column" scope="row"><label for="cb-select-<?php echo $i+1?>" class="screen-reader-text"><?php echo $row->sitemap?></label>
                    <input type="checkbox" value="1" name="post[]" id="cb-select-<?php echo $i+1?>">
                    <div class="locked-indicator"></div>
                </th>                
                <td class="post-title page-title column-title">
                    <strong><a title="Edit "Hello world!"" href="#" class="row-title"><?php echo $row->sitemap?></a> </strong>
                    <div class="locked-info">
                        <span class="locked-avatar"></span> <span class="locked-text"></span>
                    </div>
                    <div class="row-actions">
                        <span class="edit"><a title="Edit this item" href="admin.php?page=hfr_source_manager&act=edit&sm=<?php echo urlencode($row->sitemap)?>">Edit</a> | </span>
                        <span class="trash"><a href="admin.php?page=hfr_source_manager&act=delete&sm=<?php echo urlencode($row->sitemap)?>" title="Move this item to the Trash" class="submitdelete">Trash</a></span>
                    </div>
                </td>
                <td>
                	<span><?php echo $row->userBlog?></span>
                </td>
                <td class="date column-date">
                	<?php
                	if ($row->active == "1") {
                	?>
                	<a href="admin.php?page=hfr_source_manager&act=deactive&sm=<?php echo urlencode($row->sitemap)?>&status=0" alt="Deactive">Active</a>
                	<?php } else { ?>
                	<a href="admin.php?page=hfr_source_manager&act=active&sm=<?php echo urlencode($row->sitemap)?>&status=1" alt="Active">Deactive</a>
                	<?php } ?>
                </td>
            </tr>
<?php 
			}
?>
        </tbody>
    </table>
</div>